define(["require",'config/appregister',"business/special/service/http","jquery","business/services/detailNavComp"], function(require, app, httpServices){
	app.controller('specialSchoolCtrl',function($scope, $rootScope, $state, $stateParams){
		if(!angular.isUndefined($stateParams.catalogId)) {
			var catalogId=$stateParams.catalogId;
		}
		if(!angular.isUndefined($stateParams.type)) {
			var type=$stateParams.type;
		}
		if(catalogId==1){
			$scope.bannerSrc='./them/special/banner1.jpg';
		}else if(catalogId==2){
			$scope.bannerSrc='./them/special/banner2.jpg';
		}else if(catalogId==3){
			$scope.bannerSrc='./them/special/banner3.jpg';
		}else if(catalogId==4){
			$scope.bannerSrc='./them/special/banner4.jpg';
		}else if(catalogId=='5e199b0c353e476a90481464a4afb0bb'){
			$scope.bannerSrc='./them/special/banner5.jpg';
		}

		//获取课程首页信息
		getList(type,catalogId,1,20);

		function getList(type,id,pageNum,num){
			var req = {
				type:"GET",
				uri:'getListByCatalogId',
				data:{
					type:type,
					catalogId:id,
					pageNo:pageNum,
					pageSize:num
				}
			};
			httpServices.specialHttpService(req).success(function(data){
				if(!data)return;
				$scope.$apply(function(){
					if(data.code == 0) {
						$scope.category=data.data.category;
						$scope.title=$scope.category.subjectName+'——'+$scope.category.subtitle;
						$scope.data=data.data;
						$scope.pageNO=data.data.Pagination.pageNo;
						$scope.dataList=data.data.list;
						paginationConf();
					}else {
						console.log(data.msg)
					}
				});
			}).error(function(){
				console.log("分页请求失败");
			});
		};

		function paginationConf(){
			$scope.paginationConf = {
				currentPage:$scope.pageNO ,
				totalItems: $scope.data.Pagination.totalCount,
				//每页预览条数
				itemsPerPage: 20,
				//分页总数
				numberOfPages: Math.ceil($scope.data.Pagination.totalCount /20),
				// 实际分页长度
				pagesLength: 5,
				perPageOptions: [20, 40, 60, 80, 100],
				onChange:function(currentPage) {
					if(currentPage) {
						$scope.paginationConf.currentPage= currentPage;
					}
					$scope.list = [];
					$scope.pageNO = $scope.paginationConf.currentPage;
					getList(type,catalogId,$scope.pageNO,20);
				}
			};
		}
	})
});
